<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>订单列表</title>
<!-- css 样式引入 -->
<link rel="stylesheet" type="text/css"
	href="../../css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css"
	href="../../css/bootstrap-table.css" />
<link rel="stylesheet" type="text/css"
	href="../../css/bootstrap-datetimepicker.min.css" />
<link rel="stylesheet" type="text/css"
	href="../../css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="../../css/index.css">
<!-- js引入 -->
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../js/bootstrap-table.js"></script>
<script type="text/javascript" src="../../js/bootstrap-table-zh-CN.js"></script>
<script type="text/javascript"
	src="../../js/bootstrap-datetimepicker.js"></script>
<script src="js/orderList.js"></script>
</head>
<body>
	<!-- 标题 -->
	<table class="btbHead">
		<tr>
			<td style="width: 25%;"><i class="fa fa-align-justify"></i>&nbsp;订单列表</td>
		</tr>
	</table>

	<!-- 模糊查询条件 -->
	<form role="form" class="form-inline searchForm">
		<div class="form-group">
			<label for="name">查询条件</label> <input type="text"
				class="form-control" id="keyWord" placeholder="请输入订单编码"
				style="width: 250px;"> <a href="javascript:doQuery()"
				class="btn btn-default"><i class="fa fa-search"></i></a>
		</div>
	</form>

	<div class="slideLine" style="margin-top: 10px; margin-bottom: 10px;"></div>

	<!-- 数据表格 -->
	<table data-toggle="table" id="dataTable" data-pagination="true">
		<thead>
			<tr>
				<th data-field="orderCode" data-align="center">订单编码</th>
				<th data-field="orderState">订单状态</th>
				<!--<th data-field="userCode">订购人ID</th>-->
				<th data-field="userName">订购人姓名</th>
				<th data-field="userPhone">订购人电话</th>
				<th data-field="receiverName">收货人姓名</th>
				<th data-field="receiverAddress">收货人地址</th>
				<th data-field="orderValiddate" data-formatter="dateFormatter">订购日期</th>
				<th data-field="operator">操作员工号</th>
				<th data-field="payType" data-formatter="payWayFormatter">支付方式</th>
				<th data-field="payfee">支付金额（分）</th>
				<th data-field="payState" data-formatter="payStateFormatter">支付状态</th>
				<th data-field="payTime">支付时间</th>
				<th data-field="transportType"
					data-formatter="transportWayFormatter">配送方式</th>
				<th data-field="opraite" data-formatter="operateFormatter">操作</th>
			</tr>
		</thead>
	</table>


	<!--模态框-->
	<div class="modal fade" id="detailModal" tabindex="-1" role="dialog"
		aria-labelledby="detailModalLabel" aria-hidden="true">
		<div class="modal-dialog" style="width: 900px;">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="myModalLabel">订单详细信息</h4>
				</div>
				<div class="modal-body" id="iptBox">
					<form class="form-horizontal form-inline commitForm"
						id="commitForm1" role="form">
						<table width="100%">
							<tr>
								<td style="text-align: right; width: 12%;"><span>订单编码</span>
								</td>
								<td><input id="orderCode" class="form-control"
									name="orderCode" type="text" value="" style="width: 100%"></td>
								<td style="text-align: right; width: 15%;">订单状态</td>
								<td><input id="orderState" class="form-control"
									name="orderState" type="text" value="" style="width: 100%"></td>
								<td style="text-align: right; width: 14%;">订购人ID</td>
								<td><input id="userCode" class="form-control"
									name="userCode" type="text" value="" style="width: 100%"></td>
							</tr>
							<tr>
								<td style="text-align: right; width:;">订购人姓名</td>
								<td><input id="userName" class="form-control"
									name="userName" type="text" value="" style="width: 100%"></td>
								<td style="text-align: right; width:;"><span>订购人电话</span></td>
								<td><input id="userPhone" class="form-control"
									name="userPhone" type="text" value="" style="width: 100%"></td>
								<td style="text-align: right; width:;">收货人姓名</td>
								<td><input id="receiverName" class="form-control"
									name="receiverName" type="text" value="" style="width: 100%"></td>
							</tr>
							<tr>
								<td style="text-align: right;"><span>收货人固话</span></td>
								<td><input id="receivePhone" class="form-control"
									name="receivePhone" type="text" value="" style="width: 100%">
								</td>
								<td style="text-align: right;"><span>收货人手机号</span></td>
								<td><input id="receiveMobile" class="form-control"
									name="receiveMobile" type="text" value="" style="width: 100%">

								</td>
								<td style="text-align: right; width:;">收货人地址</td>
								<td><input id="receiverAddress" class="form-control"
									name="receiverAddress" type="text" value="" style="width: 100%">
								</td>
							</tr>
							<tr>
								<td style="text-align: right;"><span>订购日期</span></td>
								<td colspan=""><input id="orderValidDate"
									class="form-control" name="orderValidDate" type="text" value=""
									style="width: 100%"></td>
								<td style="text-align: right;"><span>订单应支付金额</span></td>
								<td colspan=""><input id="totalPrice" class="form-control"
									name="totalPrice" type="text" value="" style="width: 100%">
								</td>
							</tr>
							<tr>
								<td style="text-align: right;"><span>分销商工号</span></td>
								<td colspan=""><input id="operator" class="form-control"
									name="operator" type="text" value="" style="width: 100%">
								</td>
								<td style="text-align: right;"><span>订单总金额</span></td>
								<td colspan=""><input id="plusPrice" class="form-control"
									name="plusPrice" type="text" value="" style="width: 100%">
								</td>
								<td style="text-align: right;"><span>优惠扣减金额</span></td>
								<td colspan=""><input id="specialoffer"
									class="form-control" name="specialoffer" type="text" value=""
									style="width: 100%"></td>
							</tr>
							<tr>
								<td style="text-align: right;"><span>优惠券编码</span></td>
								<td colspan=""><input id="couponCood" class="form-control"
									name="couponCood" type="text" value="" style="width: 100%">
								</td>
								<td style="text-align: right;"><span>支付方式</span></td>
								<td colspan="payWay"><input id="" class="form-control"
									name="payWay" type="text" value="" style="width: 100%"></td>
								<td style="text-align: right;"><span>支付金额（分）</span></td>
								<td colspan="payFee"><input id="" class="form-control"
									name="payFee" type="text" value="" style="width: 100%">
								</td>
							</tr>
							<tr>
								<td style="text-align: right;"><span>支付状态</span></td>
								<td colspan="payState"><input id="" class="form-control"
									name="payState" type="text" value="" style="width: 100%">
								</td>
								<td style="text-align: right;"><span>支付时间</span></td>
								<td colspan="payTime"><input id="" class="form-control"
									name="payTime" type="text" value="" style="width: 100%">
								</td>
								<td style="text-align: right;"><span>配送方式</span></td>
								<td colspan="transportType"><input id=""
									class="form-control" name="transportType" type="text" value=""
									style="width: 100%"></td>
							</tr>
							<tr>
								<td style="text-align: right;"><span>配送费用（分）</span></td>
								<td colspan="transportFee"><input id=""
									class="form-control" name="transportFee" type="text" value=""
									style="width: 100%"></td>
								<td style="text-align: right;"><span>配送时限（小时）</span></td>
								<td colspan="transportTime"><input id=""
									class="form-control" name="transportTime" type="text" value=""
									style="width: 100%"></td>
							</tr>
						</table>
					</form>
					<table class="d_content form-horizontal form-inline">

					</table>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" onclick="formReset()"
						data-dismiss="modal">确定</button>
				</div>
			</div>
		</div>
	</div>
</body>

<script type="text/javascript">
	// 详细模态框监听
	$('#detailModal').on(
			'show.bs.modal',
			function(event) {
				var button = $(event.relatedTarget)
				var orderCode = button.data('ordercode')
				var dataobj = {}
				// 根据订单编码向后台请求数据
				$.ajax({
					type : "get",
					url : basePath + "/order/orderWithGoods/" + orderCode,
					async : false,
					success : function(data) {
						if (data) {
							dataobj = data.obj;
							console.log(dataobj);
						}
					},
					error : function(data) {
						alert("操作失败!");
						document.location.reload();
					}
				});
				var modal = $(this)
				var list = dataobj.list;
				var order = dataobj.order;
				modal.find('#createTime').val(order.createTime);
				modal.find('#id').val(order.id);
				modal.find('#lastModifiedTime').val(order.lastModifiedTime);
				modal.find('#operator').val(order.operator);
				modal.find('#orderCode').val(order.orderCode);
				modal.find('#orderInvaliddate').val(order.orderInvaliddate);
				modal.find('#orderState').val(order.orderState);
				modal.find('#orderValiddate').val(order.orderValiddate);
				modal.find('#payState').val(order.payState);
				modal.find('#payTime').val(order.payTime);
				modal.find('#payType').val(order.payType);
				modal.find('#payfee').val(order.payfee);
				modal.find('#plusPrice').val(order.plusPrice);
				modal.find('#receiverAddress').val(order.receiverAddress);
				modal.find('#receiverMobile').val(order.receiverMobile);
				modal.find('#receiverName').val(order.receiverName);
				modal.find('#receiverPhone').val(order.receiverPhone);
				modal.find('#specialOffer').val(order.specialOffer);
				modal.find('#totalPrice').val(order.totalPrice);
				modal.find('#transportTime').val(order.transportTime);
				modal.find('#transportType').val(order.transportType);
				modal.find('#transportfee').val(order.transportfee);
				modal.find('#userCode').val(order.userCode);
				modal.find('#userPhone').val(order.userPhone);
				modal.find('#username').val(order.username);

				for ( var i in list) {
					var k = "<tr>"
							+ "<td>买入时间:  </td><td class='form-control'> "
							+ new Date(list[i].createTime)
									.Format("yyyy-MM-dd hh:mm:ss") + "</td>"
							+ "<td>商品编码: <</td><td class='form-control'> "
							+ list[i].goodsCode + "</td>"
							+ "<td>商品价格 : </td><td class='form-control'> "
							+ list[i].price + "</td>"
							+ "<td>商品数量 : </td><td class='form-control'> "
							+ list[i].quantity + "</td>"
							+ "<td>商品总价: </td><td class='form-control'> "
							+ list[i].total + "</td>" + "<tr>";
					$(".d_content").append(k);
					console.log(list);
				}

			});

	// 详情模态框消失事件监听
	$('#detailModal').on('hide.bs.modal', function() {
		$(".d_content").html("");
		//$("commitForm1")[0].reset();
	});
</script>
</html>